module.exports = function ($scope, $modalInstance, $resource, toaster, obj, date2str){
    console.log(obj);
    $scope.obj = obj;
	$scope.date = {
		'opened': false,
		'lable' : obj.stop_time
	}

    //保存
	$scope.save = function() {
		$scope.obj.stop_time = date2str($scope.date.lable);
		if(obj.is_publicity==1 && !obj.stop_time){
			toaster.warning({title: '', body: '请填写停止公示时间.'});
			return false;
		}
		$resource('/api/as/goc/enterpriserecord/updaterecord', {}, {}).save($scope.obj, function(res){
            if (res.errcode === 0) {
                toaster.success({title: '', body: '保存成功'});
                $modalInstance.close();
            } else {
                toaster.error({title: '', body: res.errmsg});
            }
        });
    }
    
    //取消
    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
    }


    $scope.dateOpen = function ($event, item) {
		console.log('open');
		$event.preventDefault();
		$event.stopPropagation();
		item.opened = true;
	};

};